#include "D3D9_PCH.h"
#include "D3D9Light.h"

CD3DLight::CD3DLight(void)
{
	ZeroMemory( &m_Light, sizeof(D3DLIGHT9) );
	m_Light.Type		= D3DLIGHT_DIRECTIONAL;
	m_Light.Ambient		= D3DXCOLOR( 0.4f, 0.4f, 0.4f, 1.0f );
	m_Light.Diffuse		= D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f );
	m_Light.Specular	= D3DXCOLOR( 0.6f, 0.6f, 0.6f, 1.0f );
	m_Light.Direction	= D3DXVECTOR3( -5.0f, -10.0f, 1.0f );
}

CD3DLight::~CD3DLight(void)
{
}

void CD3DLight::setLightType( int eD3DLIGHT_Type ) {

	m_Light.Type = static_cast<D3DLIGHTTYPE>(eD3DLIGHT_Type);
	m_Light.Position = m_vPosition;
	m_Light.Direction = m_rRotation;
}

void CD3DLight::setAmbient( FLOAT r, FLOAT g, FLOAT b, FLOAT a ) {
	m_Light.Ambient = D3DXCOLOR( r, g, b, a );
}

void CD3DLight::setDiffuse( FLOAT r, FLOAT g, FLOAT b, FLOAT a ) {
	m_Light.Diffuse = D3DXCOLOR( r, g, b, a );
}

void CD3DLight::setSpecular( FLOAT r, FLOAT g, FLOAT b, FLOAT a ) {
	m_Light.Specular = D3DXCOLOR( r, g, b, a );
}

void CD3DLight::setEnable( BOOL bEnable ) {

	g_pDevice->SetLight( 0, &m_Light );
	g_pDevice->LightEnable( 0, bEnable );
}